<template>
  <div>
    <el-dialog :visible.sync="dialogVisible" :fullscreen="fullscreen">
      <div
        slot="title"
        style="display: flex; justify-content: space-between;align-items: center;"
      >
        <div>查看个人客户详情</div>
        <div
          style="margin-right: 30px; cursor: pointer;"
          @click="fullscreen = !fullscreen"
        >
          <img
            style="width: 18px; height: 18px;"
            :src="
              !fullscreen
                ? require('../../../assets/icon/add.png')
                : require('../../../assets/icon/fix.png')
            "
            alt=""
          />
        </div>
      </div>
      <div class="person-item">
        <div class="person-left">
          <div>姓名：</div>
          <div>{{ detailInfo.realname ? detailInfo.realname : "-" }}</div>
        </div>
        <div class="person-left">
          <div>客户经理：</div>
          <div>
            {{ detailInfo.adminNickName ? detailInfo.adminNickName : "-" }}
          </div>
        </div>
      </div>
      <div class="person-item">
        <div class="person-left">
          <div>来访日期：</div>
          <div>{{ detailInfo.visitTime ? detailInfo.visitTime : "-" }}</div>
        </div>
        <div class="person-left">
          <div>联系方式：</div>
          <div>{{ detailInfo.phone ? detailInfo.phone : "-" }}</div>
        </div>
      </div>
      <div class="person-item">
        <div class="person-left">
          <div>业务类型：</div>
          <div>{{ detailInfo.businessType | businessTypeFilter }}</div>
        </div>
      </div>

      <div class="person-item">
        <div class="person-left">
          <div>业务员：</div>
          <div>
            {{
              detailInfo.userList
                ? detailInfo.userList.map(v => v.adminName).join(" , ")
                : "-"
            }}
          </div>
        </div>
      </div>
      <div class="person-item">
        <div class="person-left">
          <div>推荐产品：</div>
          <div>{{ detailInfo.productList | productFilter }}</div>
        </div>
      </div>
      <div class="person-item">
        <div class="person-right">
          <div>备注：</div>
          <div>
            <p class="parsed-text">
              {{ detailInfo.note ? detailInfo.note : "" }}
            </p>
          </div>
        </div>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import { getCustomerPersonDetail } from "@/api/customer";
export default {
  name: "personDetail",
  filters: {
    productFilter(val) {
      if (val) {
        return val.map(item => item.name).join(",");
      } else return "-";
    },
    businessTypeFilter(val) {
      const objMap = {
        1: "贷款业务",
        2: "孵化业务"
      };
      return objMap[val];
    }
  },
  data() {
    return {
      dialogVisible: false,
      detailInfo: {},
      loading: false,
      fullscreen: false
    };
  },
  methods: {
    opendialog(row) {
      this.loading = true;
      getCustomerPersonDetail(row.id)
        .then(res => {
          this.detailInfo = res.data;
          this.loading = false;
          // this.str = res.data.remark
        })
        .finally(() => {
          this.loading = false;
        });
      //   console.log(row);
      this.dialogVisible = true;
    },
    handleClose() {
      this.dialogVisible = false;
    }
  }
};
</script>

<style lang="scss" scoped>
p {
  margin: 0;
  padding: 0;
}
.person-item {
  display: flex;
  align-items: center;
  width: 100%;
  margin-bottom: 20px;
  .person-left {
    display: flex;
    align-items: center;
    width: 48%;
    > div {
      text-align: right;
      &:nth-child(1) {
        width: 30%;
        color: #999;
      }
      &:nth-child(2) {
        color: #222;
      }
    }
  }
}
.person-right {
  display: flex;
  align-items: baseline;
  width: 100%;
  > div {
    &:nth-child(1) {
      text-align: right;
      width: 14%;
      color: #999;
    }
    &:nth-child(2) {
      width: 80%;
      background: #f5f5f5;
      padding: 0 10px;
      border-radius: 8px;
      line-height: 20px;
      border: 1px solid #eeeeee;
    }
  }
}
.parsed-text {
  white-space: pre-line; /* 保留换行 */
  margin-bottom: 20px;
  line-height: 20px;
}
</style>
